/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package au.edu.swin.unilearn.tutorialGroup;

//import au.edu.swin.unilearn.students.Student;
//import au.edu.swin.unilearn.students.StudentEntity;
import au.edu.swin.unilearn.subject.SubjectEntity;
import au.edu.swin.unilearn.universitystaff.UniversityStaffEntity;
import java.io.Serializable;
//import java.util.ArrayList;
//import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
//import javax.persistence.JoinTable;
//import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author DidierLeung
 */
@Entity
@IdClass(TutorialGroupPK.class)
@NamedQueries({
@NamedQuery(name = "findAllTutorialGroups", query = "SELECT tge FROM TutorialGroupEntity tge")
})
@Table(name = "TUTORIAL_GROUP")
public class TutorialGroupEntity implements Serializable
{
    private static final long serialVersionUID = 1L;
    @Id
    @Column
    private Integer activity_no;
    @Id
    @Column(name = "SUBJECT_CODE", nullable = false, updatable = false, insertable = false)
    private String subject_code;
    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER, optional = false)
    @JoinColumn(name = "SIMS_ID", referencedColumnName = "SIMS_ID", nullable = false)
    private UniversityStaffEntity universityStaffEntity;
    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER, optional = false)
    @JoinColumn(name = "SUBJECT_CODE", referencedColumnName = "SUBJECT_CODE", nullable = false)
    private SubjectEntity subjectEntity;
//    @ManyToMany
//    //@JoinTable(name="TUTORIAL_CLASS")
//    private List<StudentEntity> studentEntityCollection;

    public TutorialGroupEntity()
    {
    }

    public TutorialGroupEntity(Integer activity_no, String subject_code,
            UniversityStaffEntity universityStaffEntity, SubjectEntity subjectEntity)
    {
        this();
        this.setActivity_no(activity_no);
        this.setSubject_code(subject_code);
        this.setUniversityStaffEntity(universityStaffEntity);
        this.setSubjectEntity(subjectEntity);
        //studentEntityCollection = new ArrayList();
    }

    public TutorialGroup getTutorialGroupObject()
    {
        return new TutorialGroup(activity_no, subjectEntity.getSubjectObject(), 
                                universityStaffEntity.getUniversityStaffObject());
    }

    public void setTutorialGroupEntityData(TutorialGroup tg)
    {
        this.setActivity_no(tg.getActivity_no());
    }

    public Integer getActivity_no()
    {
        return activity_no;
    }

    public void setActivity_no(Integer activity_no)
    {
        this.activity_no = activity_no;
    }

    public String getSubject_code()
    {
        return subject_code;
    }

    public void setSubject_code(String subject_code)
    {
        this.subject_code = subject_code;
    }

    public UniversityStaffEntity getUniversityStaffEntity()
    {
        return universityStaffEntity;
    }

    public void setUniversityStaffEntity(UniversityStaffEntity universityStaffEntity)
    {
        this.universityStaffEntity = universityStaffEntity;
    }

    public SubjectEntity getSubjectEntity()
    {
        return subjectEntity;
    }

    public void setSubjectEntity(SubjectEntity subjectEntity)
    {
        this.subjectEntity = subjectEntity;
        this.subject_code = subjectEntity.getSubject_code();
    }

//    public List<StudentEntity> getStudentEntityCollection()
//    {
//        return studentEntityCollection;
//    }
//
//    public void setStudentEntityCollection(List<StudentEntity> studentEntityCollection)
//    {
//        this.studentEntityCollection = studentEntityCollection;
//    }
//    
//    public void enrolStudent(StudentEntity se)
//    {
//        studentEntityCollection.add(se);
//    }
}
